home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
M2
/
VGA.MOD
< prev
next >
Wrap
Text File
|
2000-09-26
|
4KB
|
297 lines
(*$S- *)
IMPLEMENTATION MODULE VGA;
FROM SYSTEM IMPORT ASSEMBLER,ADDRESS,OFS,SEG;
FROM System IMPORT AX,BX,CX,DX,ES,DI,DS,SI,Trap,XTrap;
FROM Strings IMPORT Length;
FROM Mouse IMPORT MouseOn,MouseOff;
FROM GEM IMPORT STRING;
PROCEDURE CopyVideo2Buffer(buffer : ADDRESS; x,y,w,h : CARDINAL);
VAR seg : CARDINAL;
ofs : CARDINAL;
plane : CARDINAL;
x1 : CARDINAL;
bpr : CARDINAL;
plus : CARDINAL;
BEGIN
seg := buffer.SEG;
ofs := buffer.OFS;
plane := (w*h) DIV 8;
x1 := (y*80)+(x DIV 8);
bpr := plane DIV h;
plus := (640-w) DIV 8;
MouseOff;
ASM
MOV AX,0A000H
MOV BX,seg
MOV DS,AX
MOV ES,BX
MOV DI,ofs
MOV DX,03CEH
MOV AX,0005H
OUT DX,AX
MOV BL,0
BMapLoop:
MOV CX,plane
MOV SI,x1
MOV DX,0
PUSH BX
PUSH DX
MOV DX,03CEH
MOV AH,BL
MOV AL,04H
OUT DX,AX
POP DX
CopyLoop:
MOV BL,DS:[SI]
MOV ES:[DI],BL
ADD SI,1
ADD DI,1
ADD DX,1
CMP DX,bpr
JNE Weiter
MOV DX,0
ADD SI,plus
Weiter:
SUB CX,1
CMP CX,0
JNE CopyLoop
POP BX
ADD BL,1
CMP BL,4
JNE BMapLoop
END;
MouseOn;
END CopyVideo2Buffer;
PROCEDURE CopyBuffer2Video(buffer : ADDRESS; x,y,w,h : CARDINAL);
VAR seg : CARDINAL;
ofs : CARDINAL;
plane : CARDINAL;
x1 : CARDINAL;
bpr : CARDINAL;
plus : CARDINAL;
BEGIN
seg := buffer.SEG;
ofs := buffer.OFS;
plane := (w*h) DIV 8;
x1 := (y*80)+(x DIV 8);
bpr := plane DIV h;
plus := (640-w) DIV 8;
MouseOff;
ASM
MOV AX,0A000H
MOV BX,seg
MOV DS,AX
MOV ES,BX
MOV DI,ofs
MOV DX,03CEH
MOV AX,0005H
OUT DX,AX
MOV BH,1
BMapLoop:
MOV CX,plane
MOV SI,x1
MOV DX,0
PUSH DX
MOV DX,03C4H
MOV AL,02H
MOV AH,BH
OUT DX,AX
POP DX
CopyLoop:
MOV BL,ES:[DI]
MOV DS:[SI],BL
ADD SI,1
ADD DI,1
ADD DX,1
CMP DX,bpr
JNE Weiter
MOV DX,0
ADD SI,plus
Weiter:
SUB CX,1
CMP CX,0
JNE CopyLoop
SHL BH,1
CMP BH,16
JNE BMapLoop
MOV DX,03C4H
MOV AX,0F02H
OUT DX,AX
END;
MouseOn;
END CopyBuffer2Video;
PROCEDURE ClearVideo(x,y,w,h : CARDINAL);
VAR plane : CARDINAL;
x1 : CARDINAL;
bpr : CARDINAL;
plus : CARDINAL;
BEGIN
plane := (w*h) DIV 8;
x1 := (y*80)+(x DIV 8);
bpr := plane DIV h;
plus := (640-w) DIV 8;
MouseOff;
ASM
MOV AX,0A000H
MOV DS,AX
MOV DX,03CEH
MOV AX,0005H
OUT DX,AX
MOV BH,1
BMapLoop:
MOV CX,plane
MOV SI,x1
MOV DX,0
PUSH DX
MOV DX,03C4H
MOV AL,02H
MOV AH,BH
OUT DX,AX
POP DX
CopyLoop:
MOV BL,0
MOV DS:[SI],BL
ADD SI,1
ADD DX,1
CMP DX,bpr
JNE Weiter
MOV DX,0
ADD SI,plus
Weiter:
SUB CX,1
CMP CX,0
JNE CopyLoop
SHL BH,1
CMP BH,16
JNE BMapLoop
MOV DX,03C4H
MOV AX,0F02H
OUT DX,AX
END;
MouseOn;
END ClearVideo;
PROCEDURE CheckVGA() : BOOLEAN;
BEGIN
AX := 01A00H;
Trap(010H);
IF ((AX MOD 256)=01AH) THEN
RETURN(TRUE);
ELSE
RETURN(FALSE);
END (* IF *);
END CheckVGA;
PROCEDURE SetRGB(c,r,g,b : CARDINAL);
BEGIN
AX := 01010H;
BX := c;
CX := g*256+b;
DX := r*256;
Trap(010H);
END SetRGB;
PROCEDURE PutChar(farbe,x,y : CARDINAL; zeichen : CHAR);
BEGIN
ASM
MOV AH,2
MOV BX,x
MOV DL,BL
MOV BX,y
MOV DH,BL
MOV BX,0
INT 10H
MOV AH,9
MOV CX,1
MOV AL,zeichen
MOV DX,farbe
MOV BL,DL
MOV BH,0
INT 10H
END (* ASM *);
END PutChar;
PROCEDURE PutText(farbe,x,y : CARDINAL; text : STRING);
VAR i,j : CARDINAL;
BEGIN
j := Length(text^)-1;
IF j>255 THEN j := 30; END;
MouseOff;
FOR i := 0 TO j DO
PutChar(farbe,x+i,y,text^[i]);
END (* FOR *);
MouseOn;
END PutText;
PROCEDURE SetPixel(farbe,x,y : CARDINAL);
BEGIN
ASM
MOV DX,farbe
MOV AL,DL
MOV AH,0CH
MOV BH,0
MOV DX,y
MOV CX,x
INT 10H
END (* ASM *);
END SetPixel;
PROCEDURE DrawX(farbe,x,y,xw : CARDINAL);
VAR z : CARDINAL;
BEGIN
FOR z := x TO xw DO
SetPixel(farbe,z,y);
END (* FOR *);
END DrawX;
PROCEDURE DrawY(farbe,x,y,yw : CARDINAL);
VAR z : CARDINAL;
BEGIN
FOR z := y TO yw DO
SetPixel(farbe,x,z);
END (* FOR *);
END DrawY;
PROCEDURE DrawBorder(fp,bp,x,y,w,h : CARDINAL);
VAR i : CARDINAL;
BEGIN
MouseOff;
DrawX(fp,x,y,x+w);
DrawY(fp,x,y,y+h);
DrawX(bp,x+1,y+h,x+w-1);
DrawY(bp,x+w,y+1,y+h-1);
MouseOn;
END DrawBorder;
END VGA.